package com.ruoyi.business.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ruoyi.common.core.domain.dto.LeaveSummaryDTO;
import com.ruoyi.common.core.domain.dto.leaveStatisticsDTO;
import com.ruoyi.common.core.domain.dto.wsdLeavesDTO;
import com.ruoyi.common.core.domain.entity.WsdLeaves;
import com.ruoyi.common.core.domain.vo.*;
import org.apache.ibatis.annotations.Param;

import javax.validation.constraints.NotBlank;
import java.time.LocalDate;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * 请假Mapper接口
 *
 * @author ruoyi
 * @date 2024-04-16
 */
public interface WsdLeavesMapper extends BaseMapper<WsdLeaves>
{
    /**
     * 查询请假
     *
     * @param id 请假主键
     * @return 请假
     */
    public WsdLeaves selectWsdLeavesById(Long id);

    /**
     * 查询请假列表
     *
     * @param wsdLeaves 请假
     * @return 请假集合
     */
    public List<WsdLeaves> selectWsdLeavesList(WsdLeaves wsdLeaves);

    /**
     * 新增请假
     *
     * @param wsdLeaves 请假
     * @return 结果
     */
    public int insertWsdLeaves(WsdLeaves wsdLeaves);

    /**
     * 修改请假
     *
     * @param wsdLeaves 请假
     * @return 结果
     */
    public int updateWsdLeaves(WsdLeaves wsdLeaves);

    /**
     * 删除请假
     *
     * @param id 请假主键
     * @return 结果
     */
    public int deleteWsdLeavesById(Long id);

    /**
     * 批量删除请假
     *
     * @param ids 需要删除的数据主键集合
     * @return 结果
     */
    public int deleteWsdLeavesByIds(Long[] ids);


    /**
     * 请假统计
     * @param endingDate
     * @param beginDate
     * @param schoolId
     * @return
     */
    public List<leaveStatisticsVO> leaveStatistics(leaveStatisticsDTO leaveStatisticsDTO);

    /**
     * 查询请假列表
     * @param wsdLeaves
     * @return
     */
    List<wsdLeavesVO> selectWsdLeavesLists(wsdLeavesDTO wsdLeaves);

    /**
     * 请假信息
     * @param leaveSummaryDTO
     * @return
     */
    List<LeaveSummaryVO> LeaveSummary(LeaveSummaryDTO leaveSummaryDTO);

    /**
     * 获取请假详细信息
     * @param leaveSummaryDTO
     * @return
     */
    LeaveSummaryVO getInfo(LeaveSummaryDTO leaveSummaryDTO);

    /**
     * 查询审核和未审核请假记录列表
     * @param schoolId
     * @param status
     * @return
     */
    List<wsdLeavesVO> selectWsdLeaveslistAuditing(@Param("schoolId") Long schoolId, @Param("status") List<Integer> status);

    /**
     * 根据班级 ID 获取请假申请
     * @param classId 班级 ID
     * @return 请假申请列表
     */
    List<wsdLeavesVO> getLeaveRequestsByClass(int classId);

    /**
     * 根据年级 ID 获取请假申请
     * @param gradeId 年级 ID
     * @return 请假申请列表
     */
    List<wsdLeavesVO> getLeaveRequestsByGrade(int gradeId);

    /**
     * 根据学校 ID 获取请假申请
     * @param schoolId 学校 ID
     * @return 请假申请列表
     */
    List<wsdLeavesVO> getLeaveRequestsBySchool(int schoolId);

    /**
     * 根据班级id查询请假信息
     *
     * @param classIds
     * @return
     */
    List<LeaveSummaryVO> LeaveSummaryByClassIds(@Param("classIds") List<Long> classIds);

    List<Map<String, Object>> queryLeaveCounts(@Param("today") LocalDate today, @Param("startOfWeek") LocalDate startOfWeek, @Param("endOfWeek") LocalDate endOfWeek, @Param("startOfMonth") LocalDate startOfMonth, @Param("endOfMonth") LocalDate endOfMonth, @Param("schoolId") Long schoolId);

    /**
     * 获取周的柱状图
     * @param schoolId
     * @param startOfWeek
     * @param endOfWeek
     * @return
     */
    List<Map<String, Object>> queryWeeklyLeaveCounts(@Param("schoolId") Long schoolId, @Param("startOfWeek") LocalDate startOfWeek, @Param("endOfWeek") LocalDate endOfWeek);

    List<Map<String, Object>> queryMonthlyLeaveCounts(@Param("schoolId") Long schoolId, @Param("startOfMonth") LocalDate startOfMonth, @Param("endOfMonth") LocalDate endOfMonth);


    /**
     * 获取年的柱状图
     * @param schoolId
     * @param startYear
     * @param currentYear
     * @return
     */
    List<Map<String, Object>> queryYearlyLeaveCounts(@Param("schoolId") Long schoolId, @Param("startYear") int startYear, @Param("currentYear") int currentYear);

    /**
     * 获取今天的请假情况
     *
     * @param schoolId
     * @return
     */
    leaveNumberVO todayLeaveStatus(@Param("schoolId") Long schoolId);

    List<AgencyMattersVO> agencyMatters(@Param("schoolId") Long schoolId, @Param("statusone") Integer statusone);

    Integer selectStudentsWsdLeave(@Param("studentId") String studentId, @Param("start_time") @NotBlank Date startTime, @Param("end_time") @NotBlank Date endTime);

    /**
     * 查询停餐人数
     * @param schoolId
     * @return
     */
    Integer countTodayApprovedLeaves(Long schoolId);

}
